//
//  XMHomeViewController.m
//  gpos_app
//
//  Created by apple on 2018/8/13.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "XMHomeViewController.h"
#import "Masonry.h"
#import "XMEarningsViewController.h"
#import "RankingListViewController.h"
#import "homeViewCell.h"
#import "PaymentViewController.h"
#import "GatheringViewController.h"
#import "DetailViewController.h"
#import "waKuangViewController.h"
#import "wgmeViewController.h"
#import "huaZhuanViewController.h"
#import "jymimaViewController.h"
#import "GPosAPI.h"
#import "SVProgressHUD.h"
#import "homeModel.h"
#import "AFNetworking.h"
#import "homeModel.h"
#import "TTCollectionView.h"
#import "tashuViewController.h"
#import "personViewController.h"

#import "MJRefresh.h"
#import "XMRegisterViewController.h"
#import "AppDelegate.h"
#import "jrxzViewController.h"
//#import "ChechNetStatus.h"
#import "delegateShangViewController.h"
#import "XMExchangeViewController.h"
#import "registerJysViewController.h"

#import "XMLightningViewController.h"
#import "OTCregisterViewController.h"



@interface XMHomeViewController ()<UITableViewDataSource,UITableViewDelegate,TTCollectionViewDelegate,UIApplicationDelegate>
@property (nonatomic,strong)UITableView * tableView;
@property (nonatomic,strong)homeViewCell *cell;
@property (nonatomic,strong)UIView * headerView;
@property (nonatomic,strong)UIImageView * bjImgeView;
@property (nonatomic,strong)UIView * scrollView;
@property (nonatomic,strong)UILabel * yexsLabel;
@property (nonatomic,strong)UIButton * ycButton;
@property (nonatomic,strong)UIView * gnView;
@property (nonatomic,strong)UIView * zsyView;
@property (nonatomic,strong)UIView * jrsyView;
@property (nonatomic,strong)UIView * FooterView;
@property (nonatomic,strong)UIButton * zpmButton;
@property (nonatomic,strong)UIButton * zsyButton;
//@property (nonatomic,strong)UIButton * smerweimaButton;
@property (nonatomic,strong)NSDictionary * params;
@property (nonatomic,strong)NSMutableArray * homeArr;
@property (nonatomic,strong)NSString * totalBalance;
@property (nonatomic,strong)NSString * Team;
@property (nonatomic,strong)NSString *TodayRqn;
@property (nonatomic,strong)NSString *allRan;
@property (nonatomic,strong)NSString * totalIncome;
@property (nonatomic,strong)NSString * yesterdayIncome;
@property (nonatomic,strong)NSString * noMan;
@property (nonatomic,strong)NSString * oneMan;
@property (nonatomic,strong)NSString * onePos;
@property (nonatomic,strong)NSString * twoMan;
@property (nonatomic,strong)NSString * twoPos;
@property (nonatomic,strong)UIView *lbtView;
@property (nonatomic,strong)NSMutableArray * modelArr;
@end

@implementation XMHomeViewController

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden=YES;
    self.tabBarController.tabBar.hidden=NO;
//    [self setNeedsStatusBarAppearanceUpdate];
}



- (void)viewDidLoad {
    [super viewDidLoad];
//    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    self.view.backgroundColor = [UIColor whiteColor];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(walkVCClick:) name:@"buttonLoseRespon" object:nil];
//    self.automaticallyAdjustsScrollViewInsets = NO;
//     NSLog(@"快去联网---%@",_dadianID);
   
    [self dataLoad];
    
   
}

- (void)walkVCClick:(NSNotification *)noti

{

    [self dataLoad];
}
-(void)dealloc{
    
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)dataLoad{
    
    [SVProgressHUD showWithStatus:@"加载中"];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
    [SVProgressHUD setDefaultAnimationType:SVProgressHUDAnimationTypeFlat];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
    __weak typeof(self) weakSelf = self;
    self.homeArr=[NSMutableArray new];
    self.modelArr = [NSMutableArray new];
    int user = [[[NSUserDefaults standardUserDefaults] objectForKey:@"userId"] intValue];
    self.params=[NSDictionary new];
    self.params = @{@"userId" : @(user)};
    
    dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
    // 创建全局并行
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_group_t group = dispatch_group_create();
    dispatch_group_async(group, queue, ^{
        
        // 请求一
        [GPosAPI requestTotalBalanceWithParams:weakSelf.params andCallback:^(id obj) {
            if (obj==nil) {
                NSLog(@"网络失败");
                [self UiLoadView];
                [self.tableView.mj_header endRefreshing];
                return ;
            }
            //            NSLog(@"余额---%@",[obj objectForKey:@"data"]);
            //            NSDictionary * arr = [obj objectForKey:@"data"];
           
            NSDecimalNumber * number = [[obj objectForKey:@"data"] objectForKey:@"totalBalance"];
           self.totalBalance = [NSString stringWithFormat:@"%@",@(number.floatValue)];;
            dispatch_semaphore_signal(semaphore);
        }];
        
        
    });
//    dispatch_group_async(group, queue, ^{
//
//        // 请求二
//        [GPosAPI requestHomePageWithParams:weakSelf.params andCallback:^(id obj) {
//
//            if (obj==nil) {
//                 [self UiLoadView];
//                NSLog(@"网络失败");
//                [self.tableView.mj_header endRefreshing];
//                return ;
//            }
//
//            NSLog(@"余额---%@",[obj objectForKey:@"data"]);
//            NSDictionary * dict = [obj objectForKey:@"data"];
//            NSInteger todayRank = [[dict objectForKey:@"todayRank"] integerValue];
//            NSInteger allRank = [[dict objectForKey:@"allRank"] integerValue];
//            self.TodayRqn = [NSString stringWithFormat:@"%ld",(long)todayRank];
//            self.allRan = [NSString stringWithFormat:@"%ld",(long)allRank];
//            dispatch_semaphore_signal(semaphore);
//        }];
//
//    });
    
    dispatch_group_async(group, queue, ^{
        [GPosAPI requestIncomeWithParams:weakSelf.params andCallback:^(id obj) {
            if (obj==nil) {
//                 [self UiLoadView];
                [self.tableView.mj_header endRefreshing];
                
                return ;
            }
            NSLog(@"排名---%@",obj);
            NSDictionary * dict = [obj objectForKey:@"data"];
//            float total = [[dict objectForKey:@"totalIncome"] floatValue];
//            float yesterday = [[dict objectForKey:@"yesterdayIncome"] floatValue];
//            NSNumber * nsNumber1 = @(total);
//            NSNumber * nsNumber2 = @(yesterday);
             NSDecimalNumber * number = [dict objectForKey:@"totalIncome"];
            NSDecimalNumber * number1 = [dict objectForKey:@"yesterdayIncome"];
            self.totalIncome = [NSString stringWithFormat:@"%@",@(number.floatValue)];
            self.yesterdayIncome = [NSString stringWithFormat:@"%@",@(number1.floatValue)];
            
            dispatch_semaphore_signal(semaphore);
        }];
        
    });
    //轮播图
//    dispatch_group_async(group, queue, ^{
//
//        NSDictionary * params = @{@"" : @""};
//
//        [GPosAPI requestAdvertisementWithParams:params andCallback:^(id obj) {
//
//            if (obj==nil) {
//                NSLog(@"22213123");
////                 [self UiLoadView];
//                [self.tableView.mj_header endRefreshing];
//                return ;
//
//            }
//            NSLog(@"tu---%@",[obj objectForKey:@"data"]);
//            //
//            //            self.homeArr = [obj objectForKey:@"data"];
//            NSArray * arr = [[NSArray alloc] init];
//            arr = [obj objectForKey:@"data"];
//            for (NSDictionary * dic in arr) {
//                homeModel *model = [[homeModel alloc] init];
//                model.photophoto = [dic objectForKey:@"uri"];
//                [self.homeArr addObject:model];
//                //                NSLog(@"图片--%@",model);
//            }
//            //            self.modelArr = self.homeArr;
//            //            NSLog(@"%@",self.homeArr);
//            dispatch_semaphore_signal(semaphore);
//
//
//        }];
//
//
//    });
    dispatch_group_async(group, queue, ^{
        [GPosAPI requestTeamWithParams:weakSelf.params andCallback:^(id obj) {
            NSLog(@"券友---%@",obj);
            if (obj==nil) {
                NSLog(@"12313123");
//                 [self UiLoadView];
                [self.tableView.mj_header endRefreshing];
                
            }else {
                if ([[obj objectForKey:@"code"] intValue] == 200 ) {
                    if ([obj objectForKey:@"data"] != nil) {
                        NSDictionary * dict = [obj objectForKey:@"data"];
                        NSMutableArray * arr = [dict objectForKey:@"noMan"];
                        NSLog(@"ad--%lu",(unsigned long)arr.count);
                        NSInteger oneMan = [[dict objectForKey:@"oneMan"] integerValue];
                        NSInteger onePos = [[dict objectForKey:@"onePos"] integerValue];
                        NSInteger twoMan = [[dict objectForKey:@"twoMan"] integerValue];
                        NSInteger twoPos = [[dict objectForKey:@"twoPos"] integerValue];
                        self.oneMan = [NSString stringWithFormat:@"%ld",(long)oneMan];
                        self.onePos = [NSString stringWithFormat:@"%ld",(long)onePos];
                        self.twoMan = [NSString stringWithFormat:@"%ld",(long)twoMan];
                        self.twoPos = [NSString stringWithFormat:@"%ld",(long)twoPos];
                        self.noMan = [NSString stringWithFormat:@"%lu",(unsigned long)arr.count];
                        
                        for (NSDictionary * dic in arr) {
                            homeModel *model = [[homeModel alloc] init];
                            model.phone = [dic objectForKey:@"phone"];
                            model.Myname = [dic objectForKey:@"nickName"];
                            [self.modelArr addObject:model];
                            NSLog(@"图片--%@",model);
                        }
                        
                    }
                    
                    
                }else if ([[obj objectForKey:@"code"] intValue] == 401 || [[obj objectForKey:@"code"] intValue] == 402) {
                    
                    UIStoryboard *mainStory = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
                    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"passWord"];
                    //storyboard里的ID
                    XMRegisterViewController *vc = [mainStory instantiateInitialViewController];
                    vc.navigationController.navigationBarHidden=NO;
//                    //设置当前窗口的根控制器
                    
                    [UIApplication sharedApplication].keyWindow.rootViewController=vc;
                    [SVProgressHUD showInfoWithStatus:[obj objectForKey:@"message"]];
                    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
                    [SVProgressHUD setDefaultAnimationType:SVProgressHUDAnimationTypeFlat];
                    
            
                }
                
                
            }
            
            dispatch_semaphore_signal(semaphore);
            
        }];
        
        
    });
    dispatch_group_async(group, queue, ^{
        
        // 请求三
        [GPosAPI requestGetUserMinerNumberWithParams:weakSelf.params andCallback:^(id obj) {
            if (obj == nil) {
                 [self UiLoadView];
                [self.tableView.mj_header endRefreshing];
                return ;
            }
            NSLog(@"矿机---%@",[obj objectForKey:@"data"]);
            self.Team = [obj objectForKey:@"data"];
//            NSLog(@"矿机---%@",self.Team);
            dispatch_semaphore_signal(semaphore);
        }];
        
    });
    dispatch_group_notify(group, queue, ^{
        
        // 三个请求对应三次信号等待
        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
//        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
//        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
        //在这里 进行请求后的方法，回到主线程
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD dismiss];
            NSLog(@"%@",self.homeArr);
            //更新UI操作
            [self UiLoadView];
            
        });
        
        
    });
    
    
}
- (void)UiLoadView{
    //隐藏返回提示文字
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:nil];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.hidden = YES;
    self.tableView = [[UITableView alloc] init];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    

    //    //判断网络状态
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(doWork:) name:@"netStatus" object:nil];
    
    self.tableView.mj_header=[MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(dataLoad)];
    


    [self.view addSubview:self.tableView];
    if (iPhoneX) {
        [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).with.offset(0);
            make.top.equalTo(self.view).with.offset(-44);
            make.right.equalTo(self.view).with.offset(0);
            make.bottom.equalTo(self.view).with.offset(-kSystemNavHeight);
        }];
        
    }else {
        [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).with.offset(0);
            make.top.equalTo(self.view).with.offset(0);
            make.right.equalTo(self.view).with.offset(0);
            make.bottom.equalTo(self.view).with.offset(10);
        }];
        
        
    }
    
    [self headerViewLoad];
    [self bjImagegongneng];
    [self gongnongLoadView];
    [self zsyLoadView];
    [self FooterLoadView];
    
    
}


- (void)headerViewLoad{
    
    self.headerView = [[UIView alloc] init];
    
    if (IS_IPHONE5) {
        
        self.headerView.frame = CGRectMake(0, 0, KmainScreenWidth, 431);
        
    }else if (iPhoneX) {
        self.headerView.frame = CGRectMake(0, 0, KmainScreenWidth, 530);
        
    }else {
        self.headerView.frame = CGRectMake(0, 0, KmainScreenWidth, 501);
        
    }
    
    self.headerView.backgroundColor = [UIColor colorWithRed:244/255.0f green:244/255.0f blue:244/255.0f alpha:1];
    self.headerView.userInteractionEnabled = YES;
    self.bjImgeView = [[UIImageView alloc] init];
    //开启按钮的点击
    self.bjImgeView.userInteractionEnabled = YES;
    [self.headerView addSubview:self.bjImgeView];
    
    //    self.smerweimaButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //    [self.smerweimaButton setImage:[UIImage imageNamed:@"icon_sys_h"] forState:UIControlStateNormal];
    //    [self.smerweimaButton addTarget:self action:@selector(smerweimaButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    //    [self.bjImgeView addSubview:self.smerweimaButton];
    
    if (iPhoneX) {
        
        //        [self.smerweimaButton mas_makeConstraints:^(MASConstraintMaker *make) {
        //            make.top.equalTo(self.bjImgeView).with.offset(44);
        //            make.right.equalTo(self.bjImgeView).with.offset(-20);
        //        }];
        
        [self.bjImgeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.headerView).with.offset(0);
            make.left.equalTo(self.headerView).with.offset(0);
            make.right.equalTo(self.headerView).with.offset(0);
            
        }];
        
    }else if(IS_IPHONE5) {
        //        [self.smerweimaButton mas_makeConstraints:^(MASConstraintMaker *make) {
        //            make.top.equalTo(self.bjImgeView).with.offset(25);
        //            make.right.equalTo(self.bjImgeView).with.offset(-20);
        //        }];
        
        [self.bjImgeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.headerView).with.offset(-20);
            make.left.equalTo(self.headerView).with.offset(0);
            make.right.equalTo(self.headerView).with.offset(0);
            make.height.equalTo(@200);
            
        }];
    }else {
        
        //        [self.smerweimaButton mas_makeConstraints:^(MASConstraintMaker *make) {
        //            make.top.equalTo(self.bjImgeView).with.offset(25);
        //            make.right.equalTo(self.bjImgeView).with.offset(-20);
        //        }];
        [self.bjImgeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.headerView).with.offset(-20);
            make.left.equalTo(self.headerView).with.offset(0);
            make.right.equalTo(self.headerView).with.offset(0);
            
        }];
    }
    
    self.bjImgeView.image = [UIImage imageNamed:@"banner_sy"];
    
    
    self.gnView = [[UIView alloc] init];
    self.gnView.layer.cornerRadius = 5;
    self.gnView.userInteractionEnabled = YES;
    [self.headerView addSubview:self.gnView];
    if (IS_IPHONE5) {
        
        [self.gnView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bjImgeView.mas_bottom).with.offset(-25);
            make.left.equalTo(self.headerView).with.offset(20);
            make.right.equalTo(self.headerView).with.offset(-20);
            make.height.equalTo(@84);
            
        }];
        
    }else {
        [self.gnView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bjImgeView.mas_bottom).with.offset(-40);
            make.left.equalTo(self.headerView).with.offset(20);
            make.right.equalTo(self.headerView).with.offset(-20);
            make.height.equalTo(@104);
            
        }];
        
    }
    
    self.gnView.backgroundColor = [UIColor whiteColor];
    
    self.zsyView = [[UIView alloc] init];
    self.zsyView.userInteractionEnabled = YES;
    [self.headerView addSubview:self.zsyView];
    if (IS_IPHONE5) {
        [self.zsyView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.gnView.mas_bottom).with.offset(10);
            make.left.equalTo(self.headerView).with.offset(0);
            make.right.equalTo(self.headerView).with.offset(-KmainScreenWidth/2-5);
            make.height.equalTo(@90);
            
        }];
        
    }else {
        [self.zsyView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.gnView.mas_bottom).with.offset(10);
            make.left.equalTo(self.headerView).with.offset(0);
            make.right.equalTo(self.headerView).with.offset(-KmainScreenWidth/2-5);
            make.height.equalTo(@110);
            
        }];
        
        
    }
    
    self.zsyView.backgroundColor = [UIColor whiteColor];
    
    self.jrsyView = [[UIView alloc] init];
    self.jrsyView.userInteractionEnabled = YES;
    [self.headerView addSubview:self.jrsyView];
    if (IS_IPHONE5) {
        [self.jrsyView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.gnView.mas_bottom).with.offset(10);
            make.left.equalTo(self.zsyView.mas_right).with.offset(10);
            make.right.equalTo(self.headerView).with.offset(0);
            make.height.equalTo(@90);
            
        }];
        
    }else {
        [self.jrsyView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.gnView.mas_bottom).with.offset(10);
            make.left.equalTo(self.zsyView.mas_right).with.offset(10);
            make.right.equalTo(self.headerView).with.offset(0);
            make.height.equalTo(@110);
            
        }];
        
    }
    
    self.jrsyView.backgroundColor = [UIColor whiteColor];
    
    self.scrollView = [[UIView alloc] init];
    [self.headerView addSubview:self.scrollView];
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.zsyView.mas_bottom).with.offset(10);
        make.left.equalTo(self.headerView).with.offset(0);
        make.right.equalTo(self.headerView).with.offset(0);
        make.height.equalTo(@82);
    }];
    
    //代理商
    UIImageView * delegImage = [[UIImageView alloc] init];
    delegImage.image = [UIImage imageNamed:@"WechatIMG6"];
    delegImage.userInteractionEnabled = YES;
    
    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
    [delegImage addGestureRecognizer:singleTap];
    
    [self.scrollView addSubview:delegImage];
    [delegImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.scrollView).with.offset(0);
        make.left.equalTo(self.scrollView).with.offset(0);
        make.right.equalTo(self.scrollView).with.offset(0);
        make.height.equalTo(@82);
    }];
    
//    UIView * scrView = [[UIView alloc] init];
//    scrView.backgroundColor = [UIColor whiteColor];
//    scrView.frame = CGRectMake(0, 0, KmainScreenWidth, 82);
//    [self.scrollView addSubview:scrView];
//    //    NSMutableArray * arr = [[NSMutableArray alloc] init];
//
//    homeModel *mo=[[homeModel alloc] init];
//    NSMutableArray *array=[NSMutableArray new];
//    for (mo in self.homeArr)
//    {
//        [array addObject:mo.photophoto];
//    }
//    NSLog(@"%@",array);
//    //    self.modelArr = arr;
//
//    //轮播图(可以加载网络图片)
//    //轮播图(可以加载网络图片)
//
//    TTCollectionView *collection = [[TTCollectionView alloc] initWithFrame:CGRectMake(0, 0, KmainScreenWidth, 82)];
//    // 这里是设置轮播图的播放间隔
//    collection.timeInterval = 2.0;
//    // 这里直接传图片的URL字符串(切记是字符串), 要不你还要改里面的图片赋值语句
//    collection.imagesArr =array;
//    [scrView addSubview:collection];
//    // 此属性一定要在collectionView添加到俯视图之后再设置, 这里是设置的轮播图数量
//    collection.imagesCount = array.count;
//    // 设置代理(用来解决图片的点击事件)
//    collection.collectionViewDelegate = self;

    self.tableView.tableHeaderView = self.headerView;
    
}


- (void)bjImagegongneng {
    
    UILabel * yeLabel = [[UILabel alloc] init];
    [self.bjImgeView addSubview:yeLabel];
    if (IS_IPHONE5) {
        
        [yeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bjImgeView).with.offset(40);
            make.centerX.equalTo(self.bjImgeView);
            //        make.width.equalTo(@70);
        }];
        
    }else {
        [yeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bjImgeView).with.offset(70);
            make.centerX.equalTo(self.bjImgeView);
            //        make.width.equalTo(@70);
        }];
        
        
    }
    
    yeLabel.text = @"我的余额";
    yeLabel.textColor = [UIColor whiteColor];
    yeLabel.textAlignment = NSTextAlignmentCenter;
    yeLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
    
    self.ycButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.bjImgeView addSubview:self.ycButton];
    [self.ycButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(yeLabel);
        make.left.equalTo(yeLabel.mas_right).with.offset(6);
    }];
    [self.ycButton setImage:[UIImage imageNamed:@"icon_yangjing_b"] forState:UIControlStateNormal];
    
    [self.ycButton addTarget:self action:@selector(ycbuttonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    self.yexsLabel = [[UILabel alloc] init];
    [self.bjImgeView addSubview:self.yexsLabel];
    [self.yexsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(yeLabel.mas_bottom).with.offset(17);
        make.centerX.equalTo(self.bjImgeView);
        //        make.width.equalTo(@70);
    }];
    [self.yexsLabel sizeToFit];
    self.yexsLabel.text = self.totalBalance;
    self.yexsLabel.textColor = [UIColor whiteColor];
    self.yexsLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:30];
    
    UILabel * GPOSLabe = [[UILabel alloc] init];
    [self.bjImgeView addSubview:GPOSLabe];
    [GPOSLabe mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(yeLabel.mas_bottom).with.offset(30);
        make.left.equalTo(self.yexsLabel.mas_right).with.offset(6);
        
    }];
    GPOSLabe.text = @"GPOS";
    GPOSLabe.textColor = [UIColor whiteColor];
    GPOSLabe.font = [UIFont systemFontOfSize:13];
    GPOSLabe.textAlignment = NSTextAlignmentLeft;
    
    
//    self.zpmButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    self.zpmButton.tag = 202;
//    [self.bjImgeView addSubview:self.zpmButton];
//    [self.zpmButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.yexsLabel.mas_bottom).with.offset(24);
//        make.right.equalTo(self.bjImgeView).with.offset(-KmainScreenWidth/2-26);
//        
//    }];
//    if ([self.allRan isEqualToString:@""]) {
//        self.allRan = @"0";
//    }
//    NSString * str1 = self.allRan;
//    NSString * str2 = [NSString stringWithFormat:@"总量排名: %@",str1];
//    [self.zpmButton setTitle:str2 forState:UIControlStateNormal];
//    self.zpmButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15];
//
//    [self.zpmButton addTarget:self action:@selector(zpmButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
//    UIButton *jrxzButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.bjImgeView addSubview:jrxzButton];
//    [jrxzButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.yexsLabel.mas_bottom).with.offset(24);
//        make.left.equalTo(self.bjImgeView).with.offset(KmainScreenWidth/2+26);
//
//    }];
//    if ([self.TodayRqn isEqualToString:@""]) {
//        self.TodayRqn = @"0";
//    }
//    NSString * str3 = self.TodayRqn;
//    NSString * str4 = [NSString stringWithFormat:@"今日新增用户: %@",str3];
//    [jrxzButton setTitle:str4 forState:UIControlStateNormal];
//    jrxzButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15];
//
//    [jrxzButton addTarget:self action:@selector(zpmButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.zpmButton.hidden = YES;
//    jrxzButton.hidden = YES;
    
    //新增申请转入交易所
    UIView * jysView = [[UIView alloc] init];
    jysView.backgroundColor = [UIColor whiteColor];
    [self.bjImgeView addSubview:jysView];
    [jysView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.yexsLabel.mas_bottom).with.offset(23);
        make.centerX.equalTo(self.bjImgeView);
        make.height.equalTo(@20);
        make.width.equalTo(@3);
    }];
    
    UIButton * zrjysButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [zrjysButton setTitle:@"申请转入交易所" forState:UIControlStateNormal];
    zrjysButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15];
    [self.bjImgeView addSubview:zrjysButton];
    [zrjysButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.yexsLabel.mas_bottom).with.offset(20);
        make.left.equalTo(self.bjImgeView).with.offset(20);
        make.right.equalTo(jysView.mas_left).with.offset(-20);
    }];
    [zrjysButton addTarget:self action:@selector(zrjysAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton * lightningButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [lightningButton setTitle:@"申请转入闪电网络" forState:UIControlStateNormal];
    lightningButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15];
    [self.bjImgeView addSubview:lightningButton];
    [lightningButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.yexsLabel.mas_bottom).with.offset(20);
        make.left.equalTo(jysView.mas_right).with.offset(20);
        make.right.equalTo(self.bjImgeView).with.offset(-20);
    }];
    [lightningButton addTarget:self action:@selector(lightningAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)gongnongLoadView {
    
    //    UIButton * saomaButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //    [self.gnView addSubview:saomaButton];
    
    UIButton * mingxiButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.gnView addSubview:mingxiButton];
    
    UIButton * shoukuanButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.gnView addSubview:shoukuanButton];
    
    UIButton * fukuanButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.gnView addSubview:fukuanButton];
    
    [@[ shoukuanButton, fukuanButton,mingxiButton] mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:10 leadSpacing:10 tailSpacing:10];
    
    [@[ shoukuanButton, fukuanButton,mingxiButton] mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.gnView).offset(15);
        //        make.height.mas_equalTo(mingxiButton.mas_width);
    }];
    //    [saomaButton setImage:[UIImage imageNamed:@"icon_fukuan"] forState:UIControlStateNormal];
    [mingxiButton setImage:[UIImage imageNamed:@"icon_mx"] forState:UIControlStateNormal];
    [shoukuanButton setImage:[UIImage imageNamed:@"icon_shoukuan"] forState:UIControlStateNormal];
    [fukuanButton setImage:[UIImage imageNamed:@"icon_zhuanz"] forState:UIControlStateNormal];
    
    //    [saomaButton addTarget:self action:@selector(saomaButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [mingxiButton addTarget:self action:@selector(mingxiButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [shoukuanButton addTarget:self action:@selector(shoukuanButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [fukuanButton addTarget:self action:@selector(fukuanButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    //    UILabel * saomaLabel = [[UILabel alloc] init];
    //    [self.gnView addSubview:saomaLabel];
    //    [saomaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    //        make.centerX.equalTo(saomaButton);
    //        make.top.equalTo(saomaButton.mas_bottom).with.offset(6);
    //
    //    }];
    //    saomaLabel.text = @"发送";
    //    saomaLabel.font = [UIFont systemFontOfSize:12];
    //    saomaLabel.textAlignment = NSTextAlignmentCenter;
    //
    UILabel * shoukuanLabel = [[UILabel alloc] init];
    [self.gnView addSubview:shoukuanLabel];
    [shoukuanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(shoukuanButton);
        make.top.equalTo(shoukuanButton.mas_bottom).with.offset(4);
        
    }];
    shoukuanLabel.text = @"接收";
    shoukuanLabel.font = [UIFont systemFontOfSize:12];
    shoukuanLabel.textAlignment = NSTextAlignmentCenter;
    
    UILabel * fukuanLabel = [[UILabel alloc] init];
    [self.gnView addSubview:fukuanLabel];
    [fukuanLabel  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(fukuanButton);
        make.top.equalTo(fukuanButton.mas_bottom).with.offset(4);
        
    }];
    fukuanLabel.text = @"发送";
    fukuanLabel.font = [UIFont systemFontOfSize:12];
    fukuanLabel.textAlignment = NSTextAlignmentCenter;
    
    UILabel * mingxiLabel = [[UILabel alloc] init];
    [self.gnView addSubview:mingxiLabel];
    [mingxiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(mingxiButton);
        make.top.equalTo(mingxiButton.mas_bottom).with.offset(4);
        
    }];
    mingxiLabel.text = @"明细";
    mingxiLabel.font = [UIFont systemFontOfSize:12];
    mingxiLabel.textAlignment = NSTextAlignmentCenter;
    
}



- (void)zsyLoadView {
    UIImageView * zsyImageView = [[UIImageView alloc] init];
    [self.zsyView addSubview:zsyImageView];
    [zsyImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.zsyView).with.offset(30);
        make.left.equalTo(self.zsyView).with.offset(20);
    }];
    zsyImageView.image = [UIImage imageNamed:@"icon_sy_l"];
    
    UILabel * zsyLabel = [[UILabel alloc] init];
    [self.zsyView addSubview:zsyLabel];
    [zsyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(zsyImageView);
        make.left.equalTo(zsyImageView.mas_right).with.offset(6);
    }];
    zsyLabel.text = @"总收益";
    zsyLabel.textColor = [UIColor blueColor];
    zsyLabel.font = [UIFont systemFontOfSize:13];
    
    UILabel * zsyjeLabel = [[UILabel alloc] init];
    [self.zsyView addSubview:zsyjeLabel];
    [zsyjeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(zsyImageView.mas_bottom).with.offset(18);
        make.left.equalTo(self.zsyView).with.offset(20);
    }];
    if ([self.totalIncome isEqualToString:@""]) {
        self.totalIncome = @"0";
    }
    zsyjeLabel.text = self.totalIncome;
    zsyjeLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    
    UILabel * zsyGposLabel = [[UILabel alloc] init];
    [self.zsyView addSubview:zsyGposLabel];
    [zsyGposLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(zsyImageView.mas_bottom).with.offset(25);
        make.left.equalTo(zsyjeLabel.mas_right).with.offset(3);
    }];
    zsyGposLabel.text = @"GPOS";
    zsyGposLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:13];
    
    
    
    UIImageView * jrsyImageView = [[UIImageView alloc] init];
    [self.jrsyView addSubview:jrsyImageView];
    [jrsyImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.jrsyView).with.offset(30);
        make.left.equalTo(self.jrsyView).with.offset(20);
    }];
    jrsyImageView.image = [UIImage imageNamed:@"icon_sy_l"];
    
    UILabel * jrsyLabel = [[UILabel alloc] init];
    [self.jrsyView addSubview:jrsyLabel];
    [jrsyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(jrsyImageView);
        make.left.equalTo(jrsyImageView.mas_right).with.offset(6);
    }];
    
    jrsyLabel.text = @"昨日收益";
    jrsyLabel.textColor = [UIColor blueColor];
    jrsyLabel.font = [UIFont systemFontOfSize:13];
    
    UILabel * jrsyjeLabel = [[UILabel alloc] init];
    [self.jrsyView addSubview:jrsyjeLabel];
    [jrsyjeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(jrsyImageView.mas_bottom).with.offset(18);
        make.left.equalTo(self.jrsyView).with.offset(20);
    }];
    if ([self.yesterdayIncome isEqualToString:@""]) {
        self.yesterdayIncome = @"0";
    }
    jrsyjeLabel.text = self.yesterdayIncome;
    jrsyjeLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    
    UILabel * jrsyGposLabel = [[UILabel alloc] init];
    [self.jrsyView addSubview:jrsyGposLabel];
    [jrsyGposLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(jrsyImageView.mas_bottom).with.offset(25);
        make.left.equalTo(jrsyjeLabel.mas_right).with.offset(3);
    }];
    jrsyGposLabel.text = @"GPOS";
    jrsyGposLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:13];
    
    self.zsyButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.zsyButton.tag = 205;
    [self.zsyView addSubview:self.zsyButton];
    [self.zsyButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.zsyView).with.offset(0);
        make.left.equalTo(self.zsyView).with.offset(0);
        make.right.equalTo(self.zsyView).with.offset(0);
        make.bottom.equalTo(self.zsyView).with.offset(0);
        
    }];
    [self.zsyButton addTarget:self action:@selector(zsyButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton * jrsyButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.jrsyView addSubview:jrsyButton];
    [jrsyButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.jrsyView).with.offset(0);
        make.left.equalTo(self.jrsyView).with.offset(0);
        make.right.equalTo(self.jrsyView).with.offset(0);
        make.bottom.equalTo(self.jrsyView).with.offset(0);
        
    }];
    [jrsyButton addTarget:self action:@selector(zsyButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
}



//底部视图
- (void)FooterLoadView {
    self.FooterView = [[UIView alloc] init];
    if (IS_IPHONE5) {
        self.FooterView.frame = CGRectMake(0,0, KmainScreenWidth, 110);
    }else {
        self.FooterView.frame = CGRectMake(0,0, KmainScreenWidth, 140);
        
    }
    self.FooterView.backgroundColor = [UIColor colorWithRed:244/255.0f green:244/255.0f blue:244/255.0f alpha:1];
    self.tableView.tableFooterView = self.FooterView;
    
    UIView * bottomView = [[UIView alloc] init];
    bottomView.backgroundColor = [UIColor whiteColor];
    [self.FooterView addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.FooterView).with.offset(10);
        make.left.equalTo(self.FooterView).with.offset(0);
        make.right.equalTo(self.FooterView).with.offset(0);
        make.bottom.equalTo(self.FooterView).with.offset(-10);
    }];
    
    UILabel * GPOSkjLabel = [[UILabel alloc] init];
    [bottomView addSubview:GPOSkjLabel];
    [GPOSkjLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bottomView).with.offset(25);
        make.left.equalTo(bottomView).with.offset(20);
    }];
    
    GPOSkjLabel.text = @"GPOS智能";
    GPOSkjLabel.font = [UIFont systemFontOfSize:14];
    
    UILabel * GPOSkjTxetLabel = [[UILabel alloc] init];
    [bottomView addSubview:GPOSkjTxetLabel];
    [GPOSkjTxetLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(GPOSkjLabel.mas_bottom).with.offset(12);
        make.left.equalTo(bottomView).with.offset(20);
    }];
    NSLog(@"sss--s---%@",self.Team);
    if ([self.Team isEqualToString:@""]) {
        self.Team = @"0";
    }
    //    NSLog(@"s--%@",w)
    GPOSkjTxetLabel.text = [NSString stringWithFormat:@"共有%@个GPOS智能正在计算",self.Team];
    GPOSkjTxetLabel.font = [UIFont systemFontOfSize:14];
    GPOSkjTxetLabel.textColor = [UIColor grayColor];
    //icon_kuangji
    
    UIImageView * kuangjiImage = [[UIImageView alloc] init];
    [bottomView addSubview:kuangjiImage];
    [kuangjiImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bottomView).with.offset(0);
        make.right.equalTo(bottomView).with.offset(-19);
        
    }];
    kuangjiImage.image = [UIImage imageNamed:@"icon_kuangji"];
    
    UIButton * bottomButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.FooterView addSubview:bottomButton];
    [bottomButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.FooterView).with.offset(10);
        make.left.equalTo(self.FooterView).with.offset(0);
        make.right.equalTo(self.FooterView).with.offset(0);
        make.bottom.equalTo(self.FooterView).with.offset(-10);
    }];
    [bottomButton addTarget:self action:@selector(bottomButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
}

- (void)ycbuttonAction:(UIButton *)sender {
    
    if (![self.yexsLabel.text isEqualToString:@"****"]) {
        
        [self.ycButton setImage:[UIImage imageNamed:@"icon_biyan_b"] forState:UIControlStateNormal];
        self.yexsLabel.text = @"****";
    } else {
        
        self.yexsLabel.text = self.totalBalance;
        [self.ycButton setImage:[UIImage imageNamed:@"icon_yangjing_b"] forState:UIControlStateNormal];
        
    }
    
}

//总排名
- (void)zpmButtonAction:(UIButton *)sender {
    
    if (sender.tag==202) {
        RankingListViewController *RankingListVC = [[RankingListViewController alloc] init];
        RankingListVC.ison = @"0";
        [self.navigationController pushViewController:RankingListVC animated:YES];
        NSLog(@"111");
    }else {
        
        jrxzViewController *RankingListVC = [[jrxzViewController alloc] init];
        [self.navigationController pushViewController:RankingListVC animated:YES];
        NSLog(@"222");
        
    }
    
}

//申请转入交易所
- (void)zrjysAction:(UIButton *)sender {
    
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"status"] intValue] ==2 ) {
        jymimaViewController * jymimaVC = [[jymimaViewController alloc] init];
        jymimaVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:jymimaVC animated:YES];
//        jymimaVC.hidesBottomBarWhenPushed = NO;
        
    }else if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"status"] intValue] ==1 ){
        
        NSString * stry =[[NSUserDefaults standardUserDefaults] objectForKey:@"openId"];
        NSLog(@"---openId--%@",stry);
        if ([stry isEqualToString:@""] || stry == NULL) {
//
            registerJysViewController * VC = [[registerJysViewController alloc] init];
            VC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:VC animated:YES];
//            VC.hidesBottomBarWhenPushed  = NO;
            
        }else {

            XMExchangeViewController * VC = [[XMExchangeViewController alloc] init];
            VC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:VC animated:YES];
//            VC.hidesBottomBarWhenPushed  = NO;

        }
    
    }
    
    
}

//申请转入闪电网络
- (void)lightningAction:(UIButton *)sender {
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"status"] intValue] ==2 ) {
        jymimaViewController * jymimaVC = [[jymimaViewController alloc] init];
        jymimaVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:jymimaVC animated:YES];
//        jymimaVC.hidesBottomBarWhenPushed = NO;
        
    }else if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"status"] intValue] ==1 ){
        
        NSString * stry =[[NSUserDefaults standardUserDefaults] objectForKey:@"OTC_openId"];
        if ([stry isEqualToString:@""] || stry == NULL) {
            //
            OTCregisterViewController * VC = [[OTCregisterViewController alloc] init];
            VC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:VC animated:YES];
//            VC.hidesBottomBarWhenPushed  = NO;

        }else {
//
            XMLightningViewController * VC = [[XMLightningViewController alloc] init];
            VC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:VC animated:YES];
//            VC.hidesBottomBarWhenPushed  = NO;
//
        }
        
    }
    
    
}

////扫码
//- (void)smerweimaButtonAction:(UIButton *)sender{
//    XMRichScanViewController * RichScanVC = [[XMRichScanViewController alloc] init];
//    [self.navigationController pushViewController:RichScanVC animated:YES];
//
//}
//发送
- (void)saomaButtonAction:(UIButton *)Action {
    NSLog(@"--%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"status"]);
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"status"] intValue] ==2 ) {
        jymimaViewController * jymimaVC = [[jymimaViewController alloc] init];
        [self.navigationController pushViewController:jymimaVC animated:YES];

    }else if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"status"] intValue] ==1 ){
        PaymentViewController * paymentVC = [[PaymentViewController alloc] init];
        [self.navigationController pushViewController:paymentVC animated:YES];

    }
    
}

//接收
- (void)shoukuanButtonAction:(UIButton *)action {
    
//    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"status"] intValue] ==2 ) {
//        jymimaViewController * jymimaVC = [[jymimaViewController alloc] init];
//        [self.navigationController pushViewController:jymimaVC animated:YES];
//
//    }else if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"status"] intValue] ==1 ){
        GatheringViewController * gatheringVC = [[GatheringViewController alloc] init];
        [self.navigationController pushViewController:gatheringVC animated:YES];


//    }
    
    
}


//划转
- (void)fukuanButtonAction:(UIButton *)action {
    
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"status"] intValue] ==2 ) {
        jymimaViewController * jymimaVC = [[jymimaViewController alloc] init];
        jymimaVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:jymimaVC animated:YES];
        jymimaVC.hidesBottomBarWhenPushed = NO;
        
    }else if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"status"] intValue] ==1 ){
        huaZhuanViewController * huaZhuanVC = [[huaZhuanViewController alloc] init];
        huaZhuanVC.hidesBottomBarWhenPushed = YES;
        huaZhuanVC.yue =  self.totalBalance;
        [self.navigationController pushViewController:huaZhuanVC animated:YES];
        huaZhuanVC.hidesBottomBarWhenPushed = NO;
        
    }
    
}

//明细
- (void)mingxiButtonAction:(UIButton *)action {
    
    DetailViewController * DetailVC = [[DetailViewController alloc] init];
    [self.navigationController pushViewController:DetailVC animated:YES];
    
}

//总收益 /今日收益
- (void)zsyButtonAction:(UIButton *)sender {
    NSLog(@"----总收益---");
    if (sender.tag == 205) {
        XMEarningsViewController * earningVC = [[XMEarningsViewController alloc] init];
        earningVC.isOn = @"0";
        [self.navigationController pushViewController:earningVC animated:YES];
    }else {
        
        XMEarningsViewController * earningVC = [[XMEarningsViewController alloc] init];
        [self.navigationController pushViewController:earningVC animated:YES];
        
        
    }
    
    
}


//#pragma mark - 这里实现cell的点击事件(根据index(也就是indexPath.item))
//- (void)cellClickWithIndex:(NSInteger)index {
////    NSLog(@"点击了第%ld张图片", index);
//    if (index == 1) {
////        NSLog(@"跳转");
//        delegateShangViewController * VC = [[delegateShangViewController alloc] init];
//        VC.hidesBottomBarWhenPushed = YES;
//        [self.navigationController pushViewController:VC animated:YES];
//        VC.hidesBottomBarWhenPushed = NO;
//    }
//}
//代理商
- (void)handleSingleTap:(UIGestureRecognizer *)gestureRecognizer {
    
        //        NSLog(@"跳转");
        delegateShangViewController * VC = [[delegateShangViewController alloc] init];
        VC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:VC animated:YES];
//        VC.hidesBottomBarWhenPushed = NO;
    
}

//矿机
- (void)bottomButtonAction:(UIButton *)sender {
    if (![self.Team isEqualToString:@""]) {
        waKuangViewController * wakuangVC = [[waKuangViewController alloc] init];
        wakuangVC.number = self.Team;
        [self.navigationController pushViewController:wakuangVC animated:YES];
    }
    
    
    NSLog(@"---矿机---");
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    
    return 2;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 1;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (IS_IPHONE5) {
        return 90;
    }else {
        
        return 120;
    }
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 10;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headView = [[UIView alloc]init];
    headView.backgroundColor = [UIColor colorWithRed:244/255.0f green:244/255.0f blue:244/255.0f alpha:1];
    return headView;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    homeViewCell * cell = [[homeViewCell alloc] init];
    if (indexPath.section == 0) {
        
        
        cell = [tableView dequeueReusableCellWithIdentifier:@"oneCell"];
        
        if (!cell) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"homeViewCell" owner:self options:nil] firstObject];
        }
        
        
        
    }else {
        
        cell = [tableView dequeueReusableCellWithIdentifier:@"twoCell"];
        
        if (!cell) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"homeViewCell" owner:self options:nil] lastObject];
        }
        
        
    }
    
    cell.quanyouMELabel.text = self.noMan;
    cell.quanyouRSLabel.text = self.oneMan;
    cell.quanyouTSLabel.text = self.onePos;
    
    cell.tuanduiRSLabel.text = self.twoMan;
    cell.tuanduiTSLabel.text = self.twoPos;
//    [cell.weishiyongButton addTarget:self action:@selector(weishiyongButtonAction:) forControlEvents:UIControlEventTouchUpInside];
//    [cell.taishuButton addTarget:self action:@selector(taishuButtonAction:) forControlEvents:UIControlEventTouchUpInside];
//    [cell.renshuButton addTarget:self action:@selector(personButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    return cell;
    
}

-(void)doWork:(NSNotification*)text
{
    NSString * netVal= text.userInfo[@"netType"];
//    self.tableView.mj_header=[MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(UiLoadView)];

    if ([netVal isEqualToString:@"notReachable"]) {
        [SVProgressHUD dismiss];
        [self.tableView.mj_header endRefreshing];
        [SVProgressHUD showInfoWithStatus:@"网络连接已断开"];
        [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
        [SVProgressHUD setDefaultAnimationType:SVProgressHUDAnimationTypeFlat];
        self.tableView.mj_header=[MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(UiLoadView)];
    }else{

        NSLog(@"网络已连接");
         self.tableView.mj_header=[MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(dataLoad)];
    }

}

//- (void)weishiyongButtonAction:(UIButton *)sender{
//
//    wgmeViewController *wgmeVC = [[wgmeViewController alloc] init];
//    wgmeVC.modelArr = self.modelArr;
//    [self.navigationController pushViewController:wgmeVC animated:YES];
//
//
//}
//- (void)taishuButtonAction:(UIButton *)sender{
//
//    tashuViewController * taishuVC = [[tashuViewController alloc] init];
//    [self.navigationController pushViewController:taishuVC animated:YES];
//
//}
//- (void)personButtonAction:(UIButton *)sender{
//    personViewController * personVC = [[personViewController alloc] init];
//    [self.navigationController pushViewController:personVC animated:YES];
//
//}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        NSLog(@"第一个列表");
        wgmeViewController *wgmeVC = [[wgmeViewController alloc] init];
        wgmeVC.modelArr = self.modelArr;
        [self.navigationController pushViewController:wgmeVC animated:YES];
        
    }else {
        
        NSLog(@"第二个列表");
    }
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
